/**
 * Project Name:cnsy-url-short-service
 * File Name:CsrfRequestFilter.java
 * Package Name:cn.cnsy123.shorturls.business.filter 
 * Date: 2020年4月7日-下午11:43:01
 * Copyright (c) 2020, yangpengfei@360@126.com All Rights Reserved. 
 *
 */

package cn.cnsy123.shorturls.business.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * ClassName: CsrfRequestFilter
 * 
 * @author yangpengfei
 * @date 2020年4月7日-下午11:43:01
 * @version 1.0
 * @since JDK 1.7
 */
public class CsrfRequestFilter implements Filter {
    
    private static final Logger logger = LoggerFactory.getLogger(CsrfRequestFilter.class);

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest)servletRequest;
        HttpServletResponse response = (HttpServletResponse)servletResponse;
        logger.info("请求地址:{},",request.getRequestURL().toString(),request.getHeaderNames());
        
        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {
    }

}
